package ve.com.wayoyo.wuml_case;

import ve.com.wayoyo.wuml_case.DibujoDiagramas.DiagramaER;
import ve.com.wayoyo.wuml_case.DibujoDiagramas.VistaDiagrama;
import android.app.Activity;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;

public class FactoryMenu {

	private Activity _currentActivity;
	@SuppressWarnings("unused")
	private VistaDiagrama _currentDiagrama;

	public FactoryMenu(Activity activity, VistaDiagrama diagrama) {
		_currentActivity = activity;
		_currentDiagrama = diagrama;
	}

	public void CambiarMenu(int menu, LinearLayout layout, LinearLayout fondo) {
		switch (menu) {

		case NuevoDiagrama.MENU_CLASE:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			cambioTitulo(layout);
			conectar(layout);
			agregarAtributo(layout);
			modificarAtributo(layout);
			eliminarAtributo(layout);
			agregarMetodo(layout);
			modificarMetodo(layout);
			eliminarMetodo(layout);
			eliminarClase(layout);
			break;

		case NuevoDiagrama.MENU_CONECTOR:
			// fondo.setBackgroundColor(Color.CYAN);
			fondo.setBackgroundResource(R.drawable.barramenuazulclaro_repeat);
			layout.removeAllViewsInLayout();
			this.modificarRelacion(layout);
			this.modificarCardinalidad(layout);
			this.cambioCosto(layout);
			this.eliminarConector(layout);
			break;
		case NuevoDiagrama.MENU_INTERFACE:
			// fondo.setBackgroundColor(Color.YELLOW);
			fondo.setBackgroundResource(R.drawable.barramenuamarilla_repeat);
			layout.removeAllViewsInLayout();
			this.cambioTitulo(layout);
			this.conectar(layout);
			this.agregarMetodo(layout);
			this.modificarMetodo(layout);
			this.eliminarMetodo(layout);
			this.eliminarClase(layout);
			break;
		case NuevoDiagrama.MENU_ABSTRACT:
			fondo.setBackgroundResource(R.drawable.barramenunaranja_repeat);
			layout.removeAllViewsInLayout();
			this.cambioTitulo(layout);
			this.conectar(layout);
			this.agregarAtributo(layout);
			this.modificarAtributo(layout);
			this.eliminarAtributo(layout);
			this.agregarMetodo(layout);
			this.modificarMetodo(layout);
			this.eliminarMetodo(layout);
			this.eliminarClase(layout);
			break;
		case NuevoDiagrama.MENU_ENTIDAD:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			this.cambioTitulo(layout);
			this.conectar(layout);
			this.agregarSubEntidad(layout);
			this.agregarAtributo(layout);
			this.modificarAtributo(layout);
			this.eliminarAtributo(layout);
			this.cambiarTipoCase(layout);
			this.eliminarEntidad(layout);
			break;
		case NuevoDiagrama.MENU_NODO:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			this.EditarNodo(layout);
			this.conectar(layout);
			this.CalcularDistCorta(layout);
			this.CalcularPertCpm(layout);
			break;
		case NuevoDiagrama.MENU_CASODEUSO:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			// this.EditarComponenteUML(layout, "CasoDeUso");
			this.EditarComponenteUML(layout);
			this.conectar(layout);
			break;
		case NuevoDiagrama.MENU_ACTOR:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			// this.EditarComponenteUML(layout, "Actor");
			this.EditarComponenteUML(layout);
			this.conectar(layout);
			break;
		case NuevoDiagrama.MENU_ACTIVIDAD:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			// this.EditarComponenteUML(layout, "Actividad");
			this.EditarComponenteUML(layout);
			this.conectar(layout);
			break;
		case NuevoDiagrama.MENU_DECISION:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			// this.EditarComponenteUML(layout, "Decision");
			this.EditarComponenteUML(layout);
			this.conectar(layout);
			break;
		case NuevoDiagrama.MENU_BARRA_ACTIVIDAD:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			this.conectar(layout);
			this.RotarComponente(layout);
			this.AumentarBarra(layout);
			this.ReducirBarra(layout);
			break;
		case NuevoDiagrama.MENU_INICIO_ACTIVIDAD:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			this.conectar(layout);
			this.EliminarInicio(layout);
			break;
		case NuevoDiagrama.MENU_FIN_ACTIVIDAD:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			this.conectar(layout);
			this.EliminarFin(layout);
			break;
		case NuevoDiagrama.MENU_OBJETO:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			this.EditarComponenteUML(layout);
			this.AumentarBarraBase(layout);
			this.ReducirBarraBase(layout);
			this.AgregarBarraVida(layout);
			break;
		case NuevoDiagrama.MENU_LIFE_BAR:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			this.AumentarBarraVida(layout);
			this.ReducirBarraVida(layout);
			this.conectar(layout);
			break;
		case NuevoDiagrama.MENU_CUADRO_TEXTO:
			fondo.setBackgroundResource(R.drawable.barramenuverde_repeat);
			layout.removeAllViewsInLayout();
			this.ModificarCuadroTexto(layout);
			this.EliminarCuadroTexto(layout);
		default:
			break;
		}
	}

	private void cambiarTipoCase(LinearLayout layout) {
		if (VistaDiagrama.getVista().getDiagrama() instanceof DiagramaER) {
			ImageButton bt_agregar =FactoryButton.getButton(_currentActivity,
					FactoryButton.CAMBIO_TIPO_CASE);			
			if (bt_agregar != null)
				layout.addView(bt_agregar);
		}
	}

	private void cambioTitulo(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.CAMBIO_TITULO));
	}

	private void conectar(LinearLayout layout) {
		View bt_conectar = FactoryButton.getButton(_currentActivity,
				FactoryButton.CONECTAR);
		if (bt_conectar != null)
			layout.addView(bt_conectar);
	}

	private void agregarAtributo(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.AGREGAR_ATRIBUTO));
	}

	private void modificarAtributo(LinearLayout layout) {
		View bt_modificar = FactoryButton.getButton(_currentActivity,
				FactoryButton.MODIFICAR_ATRIBUTO);
		if (bt_modificar != null)
			layout.addView(bt_modificar);
	}

	private void eliminarAtributo(LinearLayout layout) {
		View bt_eliminar = FactoryButton.getButton(_currentActivity,
				FactoryButton.ELIMINAR_ATRIBUTO);
		if (bt_eliminar != null)
			layout.addView(bt_eliminar);
	}

	private void agregarMetodo(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.AGREGAR_METODO));
	}

	private void modificarMetodo(LinearLayout layout) {
		View bt_modificar = FactoryButton.getButton(_currentActivity,
				FactoryButton.MODIFICAR_METODO);
		if (bt_modificar != null)
			layout.addView(bt_modificar);
	}

	private void eliminarMetodo(LinearLayout layout) {
		View bt_eliminar = FactoryButton.getButton(_currentActivity,
				FactoryButton.ELIMINAR_METODO);
		if (bt_eliminar != null)
			layout.addView(bt_eliminar);
	}

	private void eliminarClase(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.ELIMINAR_CLASE));
	}

	private void modificarRelacion(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.MODIFICAR_RELACION));
	}

	private void modificarCardinalidad(LinearLayout layout) {
		View bt_modificar = FactoryButton.getButton(_currentActivity,
				FactoryButton.MODIFICAR_CARDINALIDAD);
		if (bt_modificar != null)
			layout.addView(bt_modificar);
	}

	private void cambioCosto(LinearLayout layout) {
		View bt_modificar = FactoryButton.getButton(_currentActivity,
				FactoryButton.CAMBIO_COSTO);
		if (bt_modificar != null)
			layout.addView(bt_modificar);
	}

	private void eliminarConector(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.ELIMINAR_CONECTOR));
	}

	private void agregarSubEntidad(LinearLayout layout) {
		View bt_agregar = FactoryButton.getButton(_currentActivity,
				FactoryButton.AGREGAR_SUB_ENTIDAD);
		if (bt_agregar != null)
			layout.addView(bt_agregar);
	}

	private void eliminarEntidad(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.ELIMINAR_ENTIDAD));
	}

	private void EditarNodo(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.EDITAR_NODO));
	}

	private void EditarComponenteUML(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.EDITAR_COMPONENTE_UML));
	}

	private void RotarComponente(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.ROTAR_COMPONENTE));
	}

	private void AumentarBarra(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.AUMENTAR_BARRA));
	}

	private void ReducirBarra(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.REDUCIR_BARRA));
	}

	private void CalcularDistCorta(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.CALCULAR_DIST_CORTA));
	}

	private void CalcularPertCpm(LinearLayout layout) {
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.CALCULAR_PERT_CPM));
	}
	
	private void AumentarBarraBase(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.AUMENTAR_BASE_BAR));
	}
	
	private void ReducirBarraBase(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.REDUCIR_BASE_BAR));
	}
	
	private void AgregarBarraVida(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.AGREGAR_BARRA_VIDA));
	}
	
	private void AumentarBarraVida(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.AUMENTAR_BARRA_VIDA));
	}
	
	private void ReducirBarraVida(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.REDUCIR_BARRA_VIDA));
	}
	
	private void ModificarCuadroTexto(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.MODIFICAR_CUADRO_TEXTO));
	}
	
	private void EliminarCuadroTexto(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.ELIMINAR_CUADRO_TEXTO));
	}
	
	private void EliminarInicio(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.ELIMINAR_INICIO));
	}
	
	private void EliminarFin(LinearLayout layout){
		layout.addView(FactoryButton.getButton(_currentActivity,
				FactoryButton.ELIMINAR_FIN));
	}
}
